﻿using System;
using System.Reflection;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;

namespace Gollie.Administration.Service.Tasks
{
	public class TaskConfiguration : Dictionary<string, TaskProperties>
	{
		public TaskConfiguration()
		{
			string assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);

			string configFile = System.IO.Path.Combine(assemblyPath, "TaskConfiguration.xml");

			XmlDocument doc = new XmlDocument();
			doc.Load(configFile);

			XmlNodeList taskNodes = doc.SelectNodes("/*/tasks/task");
			foreach (XmlNode taskNode in taskNodes)
			{
				string name = taskNode.Attributes["name"].Value;
				this[name] = new TaskProperties(taskNode);
			}
		}
	}
}
